-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build with Bazel. #232
Build with Bazel. #232
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments about avoiding leaking headers into the rules that depend on this. gflags/gflags#233 and the associated PRs have more info.
bazel/glog.bzl
Outdated
'src/config.h.cmake.in', | ||
], | ||
outs = [ | ||
'/'.join([PACKAGE_NAME, 'config.h']) if PACKAGE_NAME else 'config.h', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it will expose config.h to users of glog in the same way as gflags/gflags#233. There are two options to deal with it in gflags/gflags#234 and gflags/gflags#235.
WORKSPACE
Outdated
tag = 'v2.2.1', | ||
) | ||
|
||
bind( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bind() is not recommended. glog.bzl should refer to @com_github_gflags_gflags//:gflags
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @drigz ,
Thanks a lot for these nice review comments! I completely did not notice them until today!
All your comments are extremely valid and valuable. Thanks!
Will reply one by one next.
bazel/glog.bzl
Outdated
name = 'internal_headers', | ||
hdrs = internal_headers, | ||
includes = [ | ||
PACKAGE_NAME, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason you're using PACKAGE_NAME everywhere? (PACKAGE_NAME is deprecated, by the way - use native.package_name() instead).
I think you could use copts = ["-Isrc"]
or strip_include_prefix = "src"
and then generate headers into src/glog/
.
bazel/glog.bzl
Outdated
], | ||
hdrs = [ | ||
'src/base/mutex.h', | ||
'src/demangle.h', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think most of these should be in hdrs
as they're not meant to be used by users of glog. See header inclusion checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that hdrs
are public interfaces, did you actually mean that most of these should be in srcs
instead of hdrs
?
bazel/glog.bzl
Outdated
'src/glog/log_severity.h', | ||
], | ||
includes = [ | ||
'src', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that any users who use #include "utilities.h"
to try to include their own utilities.h
might accidentally pick up glog's utilities.h
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super good point here. This, and the comment below, will be addressed together.
This commit addresses a few issues: 1. No longer leak config.h in a way similar to gflags/gflags#233 The solution of prefixing the path by 'glog_internal' is modified from gflags/gflags#234 2. No longer expose internal headers. 3. Replace PACKAGE_NAME with native.package_name() 4. Uers can choose namespaces via the newly added 'namespace' keyword. 5. Replace glob with explicitly listing of files. 6. Make the genrules more compact using pythonic list construction.
@drigz : I believe at this point I addressed all your previous comments:
Tested on a Ubuntu 16.04 x86_64 machine using the |
Let me defer review and approval to @drigz as I'm not familiar with Bazel. |
@qzmfranklin This all looks good to me. Thanks for the contribution! |
I'm including glog as a dependency in my bazel project, but it is not working.
and currently getting the following error:
|
@yichuan1118 I can't reproduce the issue, and the continuous build on macOS doesn't have the same problem, so we'll need more info. Could you file a separate issue, specifying:
Thanks! |
@drigz Thank you for getting back to me. After some digging I found the issue is that the gflags I'm including is a bit too old, for some reason it is causing this issue. After upgrading to gflags master, everything is working now. Thank you! |
When are you going to release this as the new version? Because we have standards to only use the released tags. |
Build with Bazel.
This PR adds native Bazel BUILD file to glog, enabling glog to be used both as an external repo (as in git_repository) or included in source.
It is easy to test:
This PR also has support for building glog with gflags. Indeed, that is the default behavior. If one wishes to build glog without gflags, he can do that via the following patch: